#pragma once

namespace one_rag {
  namespace App {



      struct GlutWindowDelegate {
        virtual void OnDisplay(){}
        virtual void OnOverlayDisplay(){}
        virtual void OnReshape(int cx, int cy){}
        virtual void OnKeyboard(unsigned char key, int x, int y){}
        virtual void OnMouse(int button, int state, int x, int y){}
      };

      enum eGlutWindowCallbacks {
        glutAllProcs = 0,
        glutDisplayProc = 1,
        glutReshapeProc = 2,
        glutOverlayDisplayProc = 4,
        glutKeyboardProc = 8,
        glutMouseProc = 16,
      };


    namespace impl {
      struct GlutWindow : WindowBase {
        // Glut Interface
        GlutWindow();//unsigned flags = 0, GlutWindowDelegate* callbacks=0);
        int CreateWindow(const char* name);
        bool SetDelegate(GlutWindowDelegate* callbacks,unsigned flags=glutAllProcs);

        void PostRedisplay();
        void MakeCurrent();


        // Standard Interface
        bool Create(const char* name, int x, int y, int w, int h);
        bool Create(const char* name, ePositionType pos, int w, int h);

        private:
        static void OnDisplay();
        static void OnOverlayDisplay();
        static void OnReshape(int cx, int cy);
        static void OnKeyboard(unsigned char key, int x, int y);
        static void OnMouse(int button, int state, int x, int y);

        private:
        int _wnd;
        GlutWindowDelegate* _callbacks;

        static Core::MutableArray<GlutWindow*> _map;

      };
    }
  }
}
